import type {baseResponse, listResponse, paramsType} from "@/api/index";
import { useAxios} from "@/api/index";

export interface sessionType {
    "id": number
    "createdAt": string
    "userID": number
    "roleID": number
    "title": string
    "aiRoleAvatar": string
    "aiRoleTitle": string
    "chatLastContent": string
    "chatCount": number
    "chatLastDate": string
    "userNickname": string
    "userAvatar": string
}
export interface sessionListParams extends paramsType{
    type: number // 1 普通用户 2 管理员
}

export function sessionListApi(params: sessionListParams): Promise<baseResponse<listResponse<sessionType>>>{
    return useAxios.get("/api/session", {params})
}


export interface sessionUpdateTitleRequest {
    sessionID: number
    title: string
}
export function sessionUpdateTitleApi(data: sessionUpdateTitleRequest):Promise<baseResponse<string>>{
    return useAxios.put("/api/session/title", data)
}


export function sessionRemoveApi(idList: number[]): Promise<baseResponse<string>> {
    return useAxios.delete("/api/session", {data: {idList}})
}

export function sessionCreateApi(roleID?: number): Promise<baseResponse<number>> {
    return useAxios.post("/api/session", {id: roleID})
}
export interface sessionDetailType {
    "id": number
    "createdAt": string
    "userID":number
    "roleID": number
    "title": string
    "roleTitle": string
    "roleAvatar": string
    "roleAbstract": string
    "roleUserChatCount": number
}

export function sessionDetailApi(id: number):Promise<baseResponse<sessionDetailType>>{
    return  useAxios.get("/api/session/" + id.toString())
}